Each path object has a fill property. This property specifies how QuickDraw GX interprets the geometry of the shape: how the shape is drawn, how the shape is hit-tested, and how certain geometric operations, like intersection or union, interpret the shape. There are two basic types of shape fills:
Note that framed fill, hollow fill, and solid fill are alternative names for open-frame fill, closed-frame fill, and even-odd fill, respectively, and that both inverse solid fill and inverse fill are alternate names for inverse even-odd fill.
A path can have any type of shape fill.
Figure 4 shows an example of a contour and how QuickDraw GX might draw it with a framed fill and with a solid fill.
Figure 4 Framed shapes versus solid shapes
QuickDraw GX actually provides seven types of shape fills:
Figure 5 shows these shape fills and the effect they have on three sample geometries.
Figure 5 The various shape fills and examples of their effects
The no-fill shape fill specifies that QuickDraw GX should not draw the shape. You can use this shape fill to hide a shape. You can specify the no-fill shape fill for any shape type.
The open-frame shape fill specifies that QuickDraw GX should draw a shape as a connected set of edges. The closed-frame shape fill indicates that QuickDraw GX should also connect the last geometric point of a contour to the first geometric point of that contour.
The even-odd shape fill and the winding shape fill indicate that QuickDraw GX should interpret the shape as a solid area--the edges of the shape represent the boundaries of the area. These two shape fills differ in the algorithm they use to determine what area to include in the shape.
The even-odd shape fill indicates that QuickDraw GX should use the even-odd rule to determine what area lies inside a shape. As QuickDraw GX scans a shape horizontally, it fills the area between every other pair of edges, as shown in Figure 7 .
Figure 6 Even-odd and winding fills
The winding shape fill indicates that QuickDraw GX should use the winding-number rule to determine what area lies inside a shape. As QuickDraw GX scans a shape horizontally, it increments a counter the first time it crosses an edge of the shape. It also notices whether the contour was directed up or down at that edge. As QuickDraw GX continues to scan the shape horizontally, every time it crosses another edge pointed in the same direction (up or down), it increments the counter, and when it crosses an edge pointing in the opposite direction (down or up), it decrements the counter. Wherever along the horizontal scan line the counter is not zero, QuickDraw GX fills the area, as is shown in Figure 7 .
Figure 7 The even-odd rule and winding-number rule algorithms
The inverse even-odd shape fill indicates the inverse of the even-odd shape fill, as shown in Figure 8 .
Figure 8 The inverse even-odd shape fill
Similarly, the inverse winding shape fill indicates the inverse of the winding shape fill.
The shape fill does more than affect the way a shape is drawn; it affects the fundamental behavior of a shape. Two shapes with the same geometry that have different shape fills can exhibit vastly different geometric behaviors. For example, the shape fill can affect
Table 2 lists the defined constants for shape fill and describes what each one means. (Note that some shape fills have two or more equivalent names.) The constants are defined in the gxShapeFills enumeration.
gxNoFill
|
0 | No fill--the shape is not filled at all. QuickDraw GX does not draw a shape with this shape fill and you may not perform geometric operations on it. You can use this shape fill to temporarily hide shapes or to prevent parts of a picture from drawing. |
gxOpenFrameFill
|
1 | Open-frame fill--the shape is outlined instead of filled. With this shape fill, QuickDraw GX interprets the shape as a connected series of straight or curved lines from the starting point of the shape geometry to the ending point (but not back to the starting point again). |
gxFrameFill
|
1 | Framed fill (same as gxOpenFrameFill ). |
gxClosedFrameFill
|
2 | Closed-frame fill--the shape is outlined instead of filled. As with the open-frame fill, QuickDraw GX interprets the shape as a series of lines (or curves) from the starting point of the shape geometry to the ending point. However, in this case, QuickDraw GX also includes a line (or curve) from the ending point to the starting point, thus closing the contour. |
gxHollowFill
|
2 | Hollow fill (same as gxClosedFrameFill ). |
gxEvenOddFill
|
3 |
Even-odd fill--the shape is filled using the even-odd rule. See Figure 6 for an illustration of this rule. |
gxSolidFill
|
3 | Solid fill (same as gxEvenOddFill ). |
gxWindingFill
|
4 | Winding fill--the shape is filled using the winding-number rule. See Figure 6 for an illustration of this rule. |
gxInverseEvenOddFill
|
5 | Inverse even-odd fill--the shape is filled in an opposite manner from the even-odd rule; everything not filled using the even-odd rule is filled using this rule. |
gxInverseSolidFill
|
5 | Inverse solid fill (same as gxInverseEvenOddFill ). |
gxInverseFill
|
5 | Inverse fill (same as gxInverseEvenOddFill ). |
gxInverseWindingFill
|
6 | Inverse winding fill--the shape is filled using the winding-number rule and then inverted. |
| Previous | Chapter Contents | Chapter Top | Next |